package com.qipay.baas.mapper;

import com.qipay.baas.model.Holiday;
import com.qipay.baas.model.HolidayExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface HolidayMapper {
    @SelectProvider(type=HolidaySqlProvider.class, method="countByExample")
    int countByExample(HolidayExample example);

    @Delete({
        "delete from `holiday`",
        "where `id` = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into `holiday` (`id`, `date`, ",
        "`name`, `is_holiday`)",
        "values (#{id,jdbcType=BIGINT}, #{date,jdbcType=VARCHAR}, ",
        "#{name,jdbcType=VARCHAR}, #{isHoliday,jdbcType=TINYINT})"
    })
    int insert(Holiday record);

    @InsertProvider(type=HolidaySqlProvider.class, method="insertSelective")
    int insertSelective(Holiday record);

    @SelectProvider(type=HolidaySqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="date", property="date", jdbcType=JdbcType.VARCHAR),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="is_holiday", property="isHoliday", jdbcType=JdbcType.TINYINT)
    })
    List<Holiday> selectByExample(HolidayExample example);

    @Select({
        "select",
        "`id`, `date`, `name`, `is_holiday`",
        "from `holiday`",
        "where `id` = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="date", property="date", jdbcType=JdbcType.VARCHAR),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="is_holiday", property="isHoliday", jdbcType=JdbcType.TINYINT)
    })
    Holiday selectByPrimaryKey(Long id);

    @UpdateProvider(type=HolidaySqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Holiday record);

    @Update({
        "update `holiday`",
        "set `date` = #{date,jdbcType=VARCHAR},",
          "`name` = #{name,jdbcType=VARCHAR},",
          "`is_holiday` = #{isHoliday,jdbcType=TINYINT}",
        "where `id` = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Holiday record);
}